#include <gtest/gtest.h>

#include "QuickJS/cutils.h"
#include "QuickJS/quickjs-libc.h"

const char defaultScript[] = R"(
  function main() {
    console.log(`hello qjs`)
  }
  main()
)";

class QjsTest : public ::testing::Test {
 public:
  void SetUp() override {
    runtime = JS_NewRuntime();
    context = JS_NewContext(runtime);
    JS_SetModuleLoaderFunc(runtime, NULL, js_module_loader, NULL); /* set loader for ES6 modules */
    js_std_init_handlers(runtime);                                 // init event handlers
    js_std_add_helpers(context, 0, nullptr);                       // add helpers like 'console', 'print'
    js_init_module_os(context, "os");                              // register module 'os'
  }

  void TearDown() override {
    js_std_free_handlers(runtime);
    JS_FreeContext(context);
    JS_FreeRuntime(runtime);
  }

  JSRuntime* runtime;
  JSContext* context;
};